﻿module UriTests


open System.IO
open NUnit.Framework;
open UriParsing;
open Uris



[<Test>]
let testParse() =
    let uri = parseUrl "http://example.com/" None
    Assert.AreEqual("http", uri.scheme)
    Assert.AreEqual("example.com", uri.host)
    Assert.AreEqual(None, uri.port)
    Assert.AreEqual("/", uri.path)
    Assert.AreEqual("http://example.com/", uri.toUrl())

[<Test>]
let testParsePort() =
    let uri = parseUrl "http://example.com:8080/" None
    Assert.AreEqual("example.com", uri.host)
    Assert.AreEqual((Some 8080), uri.port)
    Assert.AreEqual("http://example.com:8080/", uri.toUrl())

[<Test>]
let testParse2() =
    let uri = parseUrl "http://example.com/domains/reserved" None
    Assert.AreEqual("example.com", uri.host)
    Assert.AreEqual("http://example.com/domains/reserved", uri.toUrl())

[<Test>]
let testParseRel() =
    let refUri = {scheme="http";host="example.com";port=None;path="/domains/example";queryString="";fragment=""}
    let uri = parseUrl "/domains/reserved" (Some refUri)
    Assert.AreEqual("example.com", uri.host)
    Assert.AreEqual("http://example.com/domains/reserved", uri.toUrl())